package com.mcxx.modules.system.controller;

import com.mcxx.modules.system.param.AreaMappingParam;
import com.mcxx.service.DefaultRestService;
import com.yinhai.ta404.core.restservice.annotation.RestService;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.Base64Utils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;


@Slf4j
@Validated
@Api("数据管理/财政发放链接地址跳转")
@RestService({"system/finance"})
public class RedirectController extends DefaultRestService {
    @Value("${society.fundpay.redirect}")
    private String redirectURL;


    @PostMapping("redirect")
    @ApiOperation("财政发放链接地址跳转")
    public void redirect(){
        UserAccountVo userAccount = getCurUserAccount();
        log.info("财政发放链接地址跳转，当前用户：{}/{}", userAccount.getName(), userAccount.getIdCardNo());
        String token = Base64Utils.encodeToUrlSafeString(userAccount.getLoginId().getBytes());
        String url = redirectURL + "?version=v2&token=" + token;
        setData(url);
    }
}
